package com.lnsf.bookstore.web.chapter.controller;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.lnsf.bookstore.common.annotation.IgnoreAuth;
import com.lnsf.bookstore.common.annotation.LoginUser;
import com.lnsf.bookstore.common.controller.ApiBaseAction;
import com.lnsf.bookstore.web.book.service.ApiBookService;
import com.lnsf.bookstore.web.chapter.service.ApiChapterService;
import com.lnsf.bookstore.web.chapter.vo.ApiChapter;
import com.lnsf.bookstore.web.comment.service.ApiCommentService;
import com.lnsf.bookstore.web.comment.vo.ApiComment;
import com.lnsf.bookstore.web.user.vo.ApiUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping(value = "/api/chapter")
public class ApiChapterController extends ApiBaseAction{
	
	@Autowired
	private ApiBookService apiBookService;
	@Autowired
	private ApiChapterService apiChapterService;

	@RequestMapping("list")
	public Object list(Integer bookId,String view){
		Map<String, Object> resultMap = new HashMap();
		Map map = new HashMap();
		map.put("bookId",bookId);
		List<ApiChapter> list = apiChapterService.queryList(map);
		resultMap.put("chapters",list);
		return toResponsSuccess(resultMap);
	}

	@RequestMapping("detail")
	public Object detail(String link){
		Map<String, Object> resultMap = new HashMap();
		Map map = new HashMap();
		map.put("link",link);
		ApiChapter apiChapter=apiChapterService.queryObject(map);
		resultMap.put("chapter",apiChapter);
		return toResponsSuccess(resultMap);
	}





}
